//初始化
mui.init();
var mask = mui.createMask(); //遮罩层
//获取本地储存数据
var my_phone = localStorage.getItem("my_phone");
var user_id = localStorage.getItem("user_id");
var is_realname, pay_password, description;
var status = 0; //修改手机号审核状态
//返回user页面
$(document).on('tap', '.go_user', function() {
	window.top.location.href = "../trading_area/business.html";
})

$(document).on('tap', '.mui-pull-right', function() {	
	mui.openWindow({
		url: "../trading_area/business_record.html",
		extras: {
			shopName: shopName,
			shopId: shopId
		},
		createNew: true
	})
})

$(document).on('tap', '#pay_sureBtn', function() {	
	mui.openWindow({
		url: "../trading_area/business_pay.html",
		extras: {
			shopId: shopId
		},
		createNew: true
	})
})

var shopId;
var shopName;
//userinfo接口调用
function detailBiz(id) {
	mui.ajax(user_url + '/api/nearby_shop/shopDetail', {
		data: {
			"shop_id": id,
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		success: function(data) {
			console.log(JSON.stringify(data))
			if(data.code == 10000) {
				shopId = data.resp.shop_id;
				shopName = data.resp.shop_name;
				$('.mui-title').html(data.resp.shop_name);
				$('.shop_img').attr('src', data.resp.shop_logo);
			}
		},
		error: function(xhr, type, errorThrown) { //异常处理；
			console.log(type);
		}
	});
}
//页面进入执行方法
window.onload = function() {
	mui.plusReady(function() {
		var self = plus.webview.currentWebview();
		id = self.detailId;
		detailBiz(id);
		plus.nativeUI.closeWaiting(); //关闭等待
		mask.close(); //关闭遮罩层
		
		//页面刷新
		window.addEventListener('refresh_method', function(e) { //执行刷新
			location.reload();
		});
	});
}